package com.example.lottery.service.mq;

import com.example.lottery.common.config.DirectRabbitConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Component
@RabbitListener(queues = DirectRabbitConfig.DLX_QUEUE_NAME)
public class DlxDrawMqReceiver {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @RabbitHandler
    public void process(Map<String,String>messages){
        //发送消息到普通队列
        log.info("死信队列开始处理异常信息");
        rabbitTemplate.convertAndSend(DirectRabbitConfig.EXCHANGE_NAME,DirectRabbitConfig.ROUTING,messages);
    }
}
